import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
  {path: '/login',component: () => import('@/views/login/LoginUser'),hidden: true,},
  {
    path: '/',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      name: 'Dashboard',
      meta: { title: '首页', icon: 'iconfont icon-fenlei', noCache: true }
    }]
  },
  { path: '/404', redirect: '/',  hidden: true },
  {
    path: '/buddhist',
    component: Layout,
    redirect: '/buddhist/buddhist',
    children: [{
      path: 'buddhist',
      name: 'Buddhist',
      component: () => import('@/views/buddhist/Buddhist'),
      meta: { title: '佛事及金额统计', icon: 'buddhist'},
    }]
  },  
  {
    path: '/buddhistType',
    component: Layout,
    redirect: '/buddhist/buddhistType',
    children: [{
      path: 'buddhistType',
      name: 'BuddhistType',
      component: () => import('@/views/buddhist/BuddhistType'),
      meta: { title: '佛事单项统计', icon: 'buddhistType'},
    }]
  },
  {
    path: '/buddhaSupport',
    component: Layout,
    redirect: '/buddhist/buddhaSupport',
    children: [{
      path: 'buddhaSupport',
      name: 'BuddhaSupport',
      component: () => import('@/views/buddhist/BuddhaSupport'),
      meta: { title: '佛像统计', icon: 'buddhaSupport'},
    }]
  },
  {
    path: '/buddhistOrder',
    component: Layout,
    redirect: '/buddhistOrder/buddhistOrder',
    children: [{
      path: 'buddhistOrder',
      name: 'BuddhistOrder',
      component: () => import('@/views/buddhistOrder/BuddhistOrder'),
      meta: { title: '预约及金额统计', icon: 'buddhistOrder'},
    }]
  },
  {
    path: '/buddhistOrderType',
    component: Layout,
    redirect: '/buddhistOrder/buddhistOrderType',
    children: [{
      path: 'buddhistOrderType',
      name: 'BuddhistOrderType',
      component: () => import('@/views/buddhistOrder/BuddhistOrderType'),
      meta: { title: '预约单项统计', icon: 'buddhistOrderType'},
    }]
  },
  {
    path: '/paiwei',
    component: Layout,
    redirect: '/paiwei/paiwei',
    children: [{
      path: 'paiwei',
      name: 'Paiwei',
      component: () => import('@/views/paiwei/Paiwei'),
      meta: { title: '牌位统计', icon: 'paiwei'},
    }]
  },
  {
    path: '/kanwei',
    component: Layout,
    redirect: '/paiwei/kanwei',
    children: [{
      path: 'kanwei',
      name: 'Kanwei',
      component: () => import('@/views/paiwei/Kanwei'),
      meta: { title: '龛位统计', icon: 'kanwei'},
    }]
  },
  {
    path: '/expend',
    component: Layout,
    redirect: '/expend/expend',
    children: [{
      path: 'expend',
      name: 'Expend',
      component: () => import('@/views/expend/Expend'),
      meta: { title: '支出统计', icon: 'expend'},
    }]
  },
  {
    path: '/donateBuilding',
    component: Layout,
    redirect: '/donateBuilding/donateBuilding',
    children: [{
      path: 'donateBuilding',
      name: 'DonateBuilding',
      component: () => import('@/views/donateBuildings/DonateBuilding'),
      meta: { title: '募建统计', icon: 'donateBuilding'},
    }]
  },
  {
    path: '/donation',
    component: Layout,
    redirect: '/donation/donation',
    children: [{
      path: 'donation',
      name: 'Donation',
      component: () => import('@/views/donations/Donation'),
      meta: { title: '布施统计', icon: 'donation'},
    }]
  },
 
  
  //  {
  //   path: '/productType',
  //   component: Layout,
  //   redirect: '/productType/productTypeList',
  //   children: [{
  //     path: 'productTypeList',
  //     name: 'ProductType',
  //     component: () => import('@/views/productType/ProductTypeList'),
  //     meta: { title: '产品类别列表', icon: 'productType' },
  //   }]
  // },
  
  // {
  //   path: '/productType',
  //   component: Layout,
  //   redirect: '/productType/productTypeList',
  //   children: [{
  //     path: 'productTypeList',
  //     name: 'ProductType',
  //     component: () => import('@/views/productType/ProductTypeList'),
  //     meta: { title: '产品类别列表', icon: 'productType' },
  //   }]
  // },
  // {
  //   path: '/pinProduct',
  //   component: Layout,
  //   redirect: '/pinProduct/pinProductList',
  //   children: [{
  //     path: 'pinProductList',
  //     name: 'PinProduct',
  //     component: () => import('@/views/pinProduct/PinProductList'),
  //     meta: { title: '拼多多产品', icon: 'pinProduct' }
  //   }]
  // },
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router

export const asyncRoutes = [
  {
    path: '/webUser',
    component: Layout,
    redirect: '/webUser/webUserList',
    name:'WebUser',
    children: [{
      path: 'webUserList',
      name: 'WebUserList',
      component: () => import('@/views/webUser/WebUserList'),
      meta: { title: '用户列表', icon: 'webUser' }
    },{
      hidden:true,
      path:'webUserDetail',
      name:'WebUserDetail',
      component: () => import('@/views/webUser/WebUserDetail'),
      meta: { title: '用户详情', icon: 'webUserDetail' },
    }]
  },
  {
    path: '/role',
    component: Layout,
    redirect: '/role/roleList',
    name:'Role',
    children: [{
      path: 'roleList',
      name: 'RoleList',
      component: () => import('@/views/role/RoleList'),
      meta: { title: '角色列表', icon: 'role'},
    },{
      hidden: true,
      path: 'roleDetail',
      name: 'RoleDetail',
      component: () => import('@/views/role/RoleDetail'),
      meta: { title: '角色详情', icon: 'roleDetail' },
    }]
  },
 
 
]
